import http from '../utils/http'

// 用户认证相关API
export interface LoginRequest {
  username: string
  password: string
}

export interface ChangePasswordRequest {
  userId: string
  newPassword: string
}

export interface ApiResponse<T = any> {
  code: number
  message: string
  data?: T
}

// 登录
export const login = (data: LoginRequest) => {
  return http.post<ApiResponse>('/login', data)
}

// 获取用户信息
export const getUserInfo = () => {
  return http.get<ApiResponse>('/users')
}

// 修改密码
export const changePassword = (data: ChangePasswordRequest) => {
  return http.post<ApiResponse>('/users/updatePwd', data)
}

// 退出登录
export const logout = () => {
  return http.post<ApiResponse>('/logout')
}
